package com.wf.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {


    /**
     * 编码
     */
    private Integer code;

    /**
     * 消息
     */
    private String msg;

    /**
     * 具体数据
     * 自定义的data
     */
    private T data;

    /**
     * 操作成功的静态方法
     */
    public static  <T> Result<T> success(T t) {
        return new Result<T>(200,"操作成功",t);
    }

    public static <T> Result <T> fail() {
        return new Result<>(500,"操作失败",null);
    }
    public static <T> Result <T> fail(String msg) {
        return new Result<>(500,msg,null);
    }

    public static <T> Result <T> forbidden() {
        return new Result<>(403,"权限不允许",null);
    }

}

